< previous page page_598 next page >

Page 598
Type.gifListing 15.1. Testing the INSERT INTO keyword.
//
// sqlvb05.sqv - Testing the INSERT INTO keyword
//
// create a new database
dbMake sqlvb05.mdb;
// create a new table
CREATE TABLE JobTitles
   (JobID TEXT(5) CONSTRAINT PKJobTitle PRIMARY KEY,
    JobName TEXT(20),
    JobDesc MEMO
   );
// insert some data
INSERT INTO JobTitles(JobID, JobName, JobDesc) VALUES
   ('J001',
    'President',
    'Presides over the company'
   );
INSERT INTO JobTitles(JobID, JobName, JobDesc) VALUES
   ('J002',
    'Vice President',
    'Does what the President tells him to do'
   );
// display results
SELECT * FROM JobTitles;
// eof
0598-01.jpg
Figure 15.1.
The results of the 
INSERT INTO statement.
Notice that you must use a separate INSERT INTO statement for each row you want to add to the table. If you wanted to add 10 more job descriptions to the JobTitles table, you would need to add 10 more INSERT INTO statements to the script.
Also, because you defined the JobsTitles.JobID column as the primary key, you are required to fill that field with unique, non-null data each time you execute the INSERT INTO statement. If you provide a null value or leave the JobsTitles.JobID field out of the INSERT INTO statement, you get a database error message.

 
< previous page page_598 next page >

If you like this book, buy it!